<template>
	<view class="container">
		<u-list @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in indexList" :key="index">
				<u-cell :title="item.username?item.username:'找不到了~'">
					<u-avatar slot="icon" shape="square" size="35" :src="item.active"
						customStyle="margin: -3px 5px -3px 0"></u-avatar>
				</u-cell>
				<view class="content">
					{{item.content}}
				</view>
			</u-list-item>
		</u-list>

		<view class="add_float" @click="add_li">
			+
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				indexList: []
			}
		},
		onPullDownRefresh() {
			this.get_list()
			uni.stopPullDownRefresh()
		},
		onShow(){
			this.get_list()
		},
		mounted() {
			
		},
		methods: {
			get_list() {
				uniCloud.callFunction({
					name:'get_shuoshuo'
				}).then(res=>{
					console.log(res)
					if (res.errCode == 0) {
						this.indexList = res.result.data
					} else {
						uni.showToast({
							title: '网络错误~',
							icon: 'none'
						})
					}
				})
			},
			scrolltolower() {
				this.loadmore()
			},
			add_li() {
				uni.navigateTo({
					url: '/page_shuoshuo/add_shuoshuo/add_shuoshuo'
				})
			},
		}
	}
</script>

<style scoped>
	
	.container{
		height: calc(100vh - 200rpx);

	}
	.add_float {
		width: 100rpx;
		height: 100rpx;
		background: #ff8272;
		color: #fff;
		font-size: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		bottom: 200rpx;
		right: 50rpx;
		border-radius: 100rpx;
	}
	::v-deep .u-list{
		width:95%;
		margin: 0 auto;
	}
	::v-deep .u-list .u-list-item{
		border: 1px solid #ccc;
		border-radius: 10rpx;
		margin-top: 15rpx;
	}
	.content{
		padding:20rpx;
		box-sizing: border-box;
		font-size:28rpx;
	}
</style>